<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>
<body class="no-skin">
<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <form class="form-inline" action="" method="get">
                        <?php if(isset($user_group) && $user_group!=4){?>
                        <label class="inline">用户名</label>
                        <input type="text" name="user_uname" value="<?php if(isset($key)&&!empty($key)) echo $key;?>" class="form-control" id="user_uname">
                        <button type="submit" class="btn btn-info btn-sm" id="submit">
                            <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                            查询
                        </button>
                        <?php }?>
                        <span class="btn btn-warning btn-sm" id="adduser">
                            <span class="ace-icon fa fa-user icon-on-right bigger-110"></span>
                            新增支出
                        </span>
                        <?php if(isset($user_group) && $user_group!=4){?>
                        <span class="pull-right"> 总收入：<label class="label label-sm label-success"><?php echo $shouru;?></label> &nbsp; | &nbsp;</span>

                        <span class="pull-right">总支出：<label class="label label-sm label-success"><?php echo $zhichu;?></label> &nbsp; | &nbsp;</span>

                        <span class="pull-right">剩余：<label class="label label-sm label-success"><?php echo $shouru-$zhichu;?></label> &nbsp; | &nbsp;</span>
                        <?php }?>
                    </form>

                    <div class="col-xs-12">

                        </div>
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="center">ID</th>
                                <th class="center">支出用途</th>
                                <th class="center">支出金额</th>
                                <th class="center">使用时间</th>
                                <th class="center">申请凭证</th>
                                <th class="center">申请人</th>
                                <th class="center">申请时间</th>
                                <th class="center">状态</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if(isset($defray)){ foreach ($defray as $key => $val) { ?>
                                <tr>
                                    <td class="center"><?php echo $val['defray_id']; ?></td>
                                    <td class="center"><?php echo $val['defray_title']; ?></td>
                                    <?php if($val['defray_type']==2){?>
                                        <td class="center"><font style="color:red;">+<?php echo $val['defray_money']; ?></font></td>
                                    <?php }else{?>
                                        <td class="center">-<?php echo $val['defray_money']; ?></td>
                                    <?php } ?>

                                    <td class="center"><?php echo $val['defray_time']; ?></td>
                                    <?php if($val['defray_type']==2){?>
                                        <td class="center">--</td>
                                        <td class="center">--</td>
                                        <td class="center">--</td>
                                    <?php }else{?>
                                        <td class="center"><a class="open" href="javascript:;" val="<?php echo base_url($val['defray_pic']); ?>">查看详细</a>&nbsp;</td>
                                        <td class="center"><?php echo $val['user_uname']; ?></td>
                                        <td class="center"><?php echo date("Y-m-d",$val['defray_add_time']); ?></td>
                                    <?php } ?>

                                    <?php if($val['defray_type']==2){?>
                                        <td class="center"><span class="label label-sm label-success">已完成</span></td>
                                    <?php }else{?>
                                        <td class="center">
                                            <?php if($val['defray_status']==1){ ?><span class="label label-sm label-yellow">审核中</span><?php }?>
                                            <?php if($val['defray_status']==2){ ?><span class="label label-sm label-success">已同意</span><?php }?>
                                            <?php if($val['defray_status']==3){ ?><span class="label label-sm label-fail">已拒绝</span><?php }?>
                                        </td>
                                    <?php } ?>
                                    <?php if(isset($user) && $user['user_group']!=4){?>
                                        <?php if($val['defray_type']==2){?>
                                            <td class="center">--</td>
                                        <?php }else{?>
                                            <td class="center">
                                                <?php if($val['defray_status']==1){?>
                                                    <a class="agree" href="javascript:;" val="<?php echo site_url(X_URL.'defray/agree/'.$val['defray_id']);?>" title="同意"><span class="btn-xs btn-success">同意</span></a>&nbsp;
                                                    <a class="del" href="javascript:;" val="<?php echo site_url(X_URL.'defray/reject/'.$val['defray_id']);?>" title="拒绝"><span class="btn-xs btn-danger">拒绝</span></a>
                                                <?php }?>
                                                <?php if($val['defray_status']==2){?>
                                                    <span class="label label-sm label-success">已同意</span>
                                                <?php }?>
                                                <?php if($val['defray_status']==3){?>
                                                    <span class="label label-sm label-fail">已拒绝</span>
                                                <?php }?>
                                            </td>
                                        <?php } ?>
                                    <?php }else{?>
                                        <td class="center">--</td>
                                    <?php }?>
                                </tr>
                            <?php } }?>
                            </tbody>
                        </table>
                        <?php if(isset($pagination)){?><ul class="pagination"><?php echo $pagination;?></ul><?php }?>
<!--                        {$page}-->
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
    </div><!-- /.main-content -->

<?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    $(function () {
        $("#officialnews ul").html('<div class="ace-icon fa fa-spinner fa-spin orange"></div>');
    })
    $("#adduser").click(function () {
        window.location.href="add";
    });
    $(".agree").click(function () {
        var url = $(this).attr('val');
        bootbox.confirm({
            title: "系统提示",
            message: "确定要同意?",
            callback: function (result) {
                if (result) {
                    window.location.href = url;
                }
            },
            buttons: {
                "cancel": {"label": "取消"},
                "confirm": {
                    "label": "确定",
                    "className": "btn-danger"
                }
            }
        });
    });

    $(".del").click(function () {
        var url = $(this).attr('val');
        bootbox.confirm({
            title: "系统提示",
            message: "确定要拒绝?",
            callback: function (result) {
                if (result) {
                    window.location.href = url;
                }
            },
            buttons: {
                "cancel": {"label": "取消"},
                "confirm": {
                    "label": "确定",
                    "className": "btn-danger"
                }
            }
        });
    });
    $(".open").click(function () {
        var url = $(this).attr('val');
        //页面层
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['800px', '800px'], //宽高
            content: '<img src="'+url+'">'
        });
    })

</script>
</body>
</html>
